﻿using CRM.Admin.Contracts.Contract.Customer;
using KingsSharp.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CRM.Admin.Contracts.Dto.Customer;
using CRM.Admin.Contracts.Model.Customer;
using KingsSharp.Common.Data;
using KingsSharp.Core.Data;
using KingsSharp.Common;
using CRM.Admin.Contracts.Model.Map;

namespace CRM.Admin.Services.Service.Customer
{
    public class NetWorkService : ServiceBase, INetworkService
    {
        private IRepository<NetworkInfo, Guid> netWorkRepository;
        public NetWorkService(IRepository<NetworkInfo, Guid> _netWorkRepository)
            :base(_netWorkRepository.UnitOfWork)
        {
            netWorkRepository = _netWorkRepository;
        }
        public IQueryable<NetworkInfo> Networks {get { return netWorkRepository.Entities; }}
       

        public OperationResult Insert(params NetworkDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            foreach (var t in dtos)
            {
                t.Id = Guid.NewGuid();
                t.CreateTime = DateTime.Now;
            }
            var result = netWorkRepository.Insert(dtos);
            return result;
        }
        public OperationResult Update(params NetworkDto[] dtos)
        {
            dtos.CheckNotNull("dtos");
            var result = netWorkRepository.Update(dtos);
            return result;
        }
    }
}
